/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package phan.connection;


import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
import java.io.BufferedReader;
import java.io.FileReader;

public class Rapport {

    private String fileText;
    boolean writeToFile;
    private Hashtable errors;
    private final String url="D:/PHAN TRONG HIEU/LostObjetAdm/web/Adminnistrateur/Recherche/";
   
    private String type;

    public Rapport() {

            fileText="";
            errors = new Hashtable();
            type="";
    }



     public String getErrorMsg(String s) {
        String errorMsg = (String) getErrors().get(s.trim());
        return (errorMsg == null) ? "" : errorMsg;
    }

      public Hashtable getErrors() {
        return errors;
    }

    /**
     * @param errors the errors to set
     */
    public void setErrors(Hashtable errors) {
        this.errors = errors;

    }

    public boolean getWriteToFile() {
        try {
                 String path="";
                 path=this.url+type+".txt";
                 System.out.print("duong dan save file"+path);
                 BufferedWriter out = new BufferedWriter(new FileWriter(path,true));
                 out.newLine();
                 out.write("-----------------------");
                 out.write(this.getFileText());
                 out.write("-----------------------");
                 out.close();
                writeToFile = true;

        } catch (IOException e) {
            writeToFile = false;
            //Log the exception here
            e.printStackTrace();
        }
        return writeToFile;
    }

    public void setWriteToFile(boolean writeToFile) {
        this.writeToFile = writeToFile;
    }

    /**
     * @return the fileText
     */
    public String getFileText() {
        return fileText;
    }

    /**
     * @param fileText the fileText to set
     */
    public void setFileText(String fileText) {
        this.fileText = fileText;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }


}


